/*
 * OpenParts
 * A dynamic-loading components framework for GWT
 * Copyright (C) 2011 Christophe Bouthier  [chris{AT}binary-gastronome{DOT}fr]
 *
 * This work is partially based on work I have done at INRIA (http://www.inria.fr) 
 * in the context of the Qualipso European Project (http://qualipso.org/),
 * The work done at INRIA is Copyright (C) 2006-2011 INRIA
 *
 * This work is distributed under the LGPL version 3
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. See the GNU
 * Lesser General Public License in LGPL.txt for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package fr.openparts.opshowcase.eventmodule1.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

import fr.openparts.opshowcase.eventmodule1.client.presenter.EventModule1Presenter;
import fr.openparts.opshowcase.eventmodule1.client.resources.EventModule1Resources;

/**
 * View of a Module 1 of Dispatch Event for OpenParts Showcase.
 * 
 * @author Christophe Bouthier [chris{AT}binary-gastronome{DOT}fr]
 * @creation.date 26 January 2011
 */
public class EventModule1View extends Composite {

    interface EventModule1ViewUiBinder extends UiBinder<Widget, EventModule1View> {}
    private static EventModule1ViewUiBinder uiBinder = GWT.create(EventModule1ViewUiBinder.class);

    protected EventModule1Presenter presenter;

    @UiField
    protected EventModule1Resources resources;
    
    @UiField
    protected FlowPanel content;

    /**
     * Constructor.
     */
    public EventModule1View(final EventModule1Presenter presenter) {
        initWidget(uiBinder.createAndBindUi(this));
        resources.style().ensureInjected();
        this.presenter = presenter;
    }

    /**
     * Display an event in the view.
     */
    public void displayEvent(final String event, final String param) {
        String msg = "module 1 received " + event;
        if (param != null) {
            msg += " with param " + param;
        }
        final Label msgLabel = new Label(msg);
        msgLabel.addStyleName(resources.style().message());
        content.add(msgLabel);
    }
    
}
